package cn.ffcs.uec.wBStaffInfo.action;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.zkoss.zhtml.Messagebox;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Components;

import cn.ffcs.raptornuke.plugin.common.zk.ctrl.BasePortletComposer;
import cn.ffcs.raptornuke.plugin.common.zk.util.ZkUtil;
import cn.ffcs.raptornuke.portal.theme.ThemeDisplay;
import cn.ffcs.uec.outStaff.manager.UecOutStaffInfomationManager;
import cn.ffcs.uec.outStaff.manager.UecOutStaffManager;
import cn.ffcs.uec.outStaff.model.UecOutStaffInfo;
import cn.ffcs.uec.outStaff.vo.UecOutStaffInfomationVo;
import cn.ffcs.uec.wBStaffInfo.action.bean.WbStaffMainBean;
import cn.ffcs.uom.common.util.ApplicationContextUtil;
import cn.ffcs.uom.common.util.IPortletInfoProvider;
import cn.ffcs.uom.common.util.PlatformUtil;
import cn.ffcs.uom.common.util.PubUtil;
import cn.ffcs.uom.common.util.StrUtil;
import cn.ffcs.uom.common.util.UomZkUtil;

@Controller
@Scope("prototype")
public class WbStaffInfoMainComposer extends BasePortletComposer implements IPortletInfoProvider {

    private static final long serialVersionUID = -5929030282722775845L;

    private WbStaffMainBean bean = new WbStaffMainBean();

    private UecOutStaffInfo uecOutStaffInfo=new UecOutStaffInfo();

    private UecOutStaffInfomationVo uecOutStaffInfomationVo = new UecOutStaffInfomationVo();
    private UecOutStaffInfomationManager uecOutStaffInfomationManager = (UecOutStaffInfomationManager) ApplicationContextUtil
			.getBean("uecOutStaffInfomationManager");
    private UecOutStaffManager uecOutStaffManager = (UecOutStaffManager) ApplicationContextUtil
            .getBean("uecOutStaffManager");
    


    @Override
    public String getPortletId() {
        return super.getPortletId();
    }

    @Override
    public ThemeDisplay getThemeDisplay() {
        return super.getThemeDisplay();
    }

    @Override
    public void doAfterCompose(Component comp) throws Exception {
        super.doAfterCompose(comp);
        UomZkUtil.autoFitHeight(comp);// 使用<borderlayout>时，需要加上这句进行初始化，不然从仓库调出的页面，不能显示
        Components.wireVariables(comp, bean);
    }

    /**
     * 界面初始化
     * 
     * @throws Exception
     */
    public void onCreate$wbStaffInfoMainWin() throws Exception {
    	this.binbBean();
    }
    private void binbBean() throws InterruptedException{
		if (StrUtil.isNullOrEmpty(PlatformUtil.getCurrentUser())) {
			ZkUtil.showError("当前登录用户不存在!", "错误提示");
			return;
		} else {
			String screenName = PlatformUtil.getCurrentUser().getScreenName();
			uecOutStaffInfomationVo.setPsnCode(screenName.toUpperCase());
			uecOutStaffInfomationVo = uecOutStaffInfomationManager
					.qryUecOutStaffContractByUecOutStaffInfo(uecOutStaffInfomationVo);
		}
		if (uecOutStaffInfomationVo != null) {
			uecOutStaffInfo.setOutStaffId(uecOutStaffInfomationVo
					.getOutStaffId());
		}
		uecOutStaffInfo = uecOutStaffManager
				.findUecOutStaffInfoById(uecOutStaffInfo);
		if (null == uecOutStaffInfo) {
			Messagebox.show("人员信息获取失败！");
			return;
		}
		
		PubUtil.fillBeanFromPo(uecOutStaffInfomationVo, bean);
		
		
	}
}
